{template 'common/header'}
<div class="panel panel-default" id="app" ng-controller="rootCtrl">
    <div class="panel-heading">
        按手机号获取微信openid
    </div>
    <div class="panel-body">
         <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="padding-top: 1rem;">手机号</label>
            <div class="col-sm-8 col-lg-9 col-xs-12">
                <div class="input-group">
                    <span class="input-group-addon" style="width:100px">phone</span>
                    <input name="phone" id="phone" type="text" class="form-control" value="" />
                </div>
            </div>
        </div>
        <br/><br/>
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label" style="padding-top: 1rem;padding-bottom: 2rem;">微信openid</label>
            <div class="col-sm-8 col-lg-9 col-xs-12">
                <div class="input-group">
                    <span class="input-group-addon" style="width:100px">openid</span>
                    <input name="openid" type="text" class="form-control" value="" readonly="readonly" style="width:300px" />
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-md-offset-2 col-lg-offset-1 col-xs-12 col-sm-10 col-md-10 col-lg-11">
                <input id="done" name="done" type="button" class="btn btn-primary span3" value="获取openid"></input>
            </div>
        </div>
    </div>
</div>
<script>
$('#done').click(function(){
    var mobile = $('#phone').val();
    if (!mobile) {
		alert('请输入您的手机号码！');
		return false;
	}
	if (mobile.search(/^([0-9]{11})?$/) == -1) {
		alert('请输入正确的手机号码！');
		return false;
	}

    var phone = $("input[name='phone']").val();
     var post = {"phone": phone};
        post.act = 'edit';
            $.post("",post,function(data){
                if(data.status==1){
                    $("input[name='openid']").val(data.openid);
                }else{
                    alert("该手机号未注册！");
                }
            },'json')
    });
</script>
{template 'common/footer'}